{% load static %}

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>分光计实验数据计算器</title>
    <script src="{% static 'js/lib/bignumber.js' %}"></script>
    <style>
        body {
            margin: 0;
            background-color: #f2f2f2;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            background-color: #fcfcfc;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            /* overflow: scroll; */
        }

        h1 {
            text-align: center;
        }

        table {
            border-collapse: collapse;
            width: 100%;
            margin: 20px auto;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        }

        th,
        td {
            border: 1px solid #ddd;
            padding: 2px;
            text-align: center;
            white-space: wrap;
        }

        th {
            background-color: #f2f2f2;
        }

        .input-field {
            border: 1px solid #ccc;
            border-radius: 5px;
            outline: none;
            font-size: 16px;
            max-width: 200px;
            padding: 5px;
        }

        .input-field2 {
            border: 1px solid #ccc;
            border-radius: 5px;
            outline: none;
            font-size: 16px;
            max-width: 50px;
            padding: 5px;
        }

        .button {
            padding: 10px 20px;
            margin-right: 10px;
            margin-bottom: 10px;
            background-color: #4caf50;
            color: #fff;
            border: none;
            border-radius: 5px;
            font-size: 14px;
            cursor: pointer;
        }

        .button:hover {
            background-color: #45a049;
        }
    </style>
</head>

<body>
    <h1>分光计实验数据计算器</h1>
    <br>
    <div class="container">
        <div class="section">
            <button class="button" onclick="DoCalculate()">计算</button>
        </div>
        <table id="First">
            <tbody>
                <tr>
                    <th style="font-size:16px;" colspan="3"> 表一 反射法测顶角</th>
                </tr>
                <tr>
                    <th>次数</th>
                    <td>1</td>
                    <td>2</td>
                </tr>
                <tr>
                    <th>Φ1（前两项必填）</th>
                    <!-- <td><input type="text" name="Φ1（度）" class="input-field" id="1652"></td> -->
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>Φ2（前两项必填）</th>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>Φ1＇（前两项必填）</th>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>Φ2＇（前两项必填）</th>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="1652">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>Φ1-Φ2（度）</th>
                    <td><input type="text" name="Φ1-Φ2（度）" class="input-field" id="1660"></td>
                    <td><input type="text" name="Φ1-Φ2（度）" class="input-field" id="1661"></td>
                </tr>
                <tr>
                    <th>Φ1＇-Φ2＇（度）</th>
                    <td><input type="text" name="Φ1＇-Φ2＇（度）" class="input-field" id="1662"></td>
                    <td><input type="text" name="Φ1＇-Φ2＇（度）" class="input-field" id="1663"></td>
                </tr>
                <tr>
                    <th>三棱镜顶角测量结果（度）</th>
                    <td><input type="text" name="三棱镜顶角测量结果（度）" class="input-field" id="1664"></td>
                    <td><input type="text" name="三棱镜顶角测量结果（度）" class="input-field" id="1665"></td>
                </tr>
                <tr>
                    <th>顶角平均值（度）</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="顶角平均值（度）" class="input-field" id="1666"></td>
                </tr>
                <tr>
                    <th>顶角的误差（度）</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="顶角的误差（度）" class="input-field" id="1667"></td>
                </tr>
                <tr>
                    <th>顶角的结果表示（度）</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="顶角的结果表示（度）" class="input-field" id="1668" value="±"></td>
                </tr>
            </tbody>
        </table>

        <table id="Second" border="1" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <th style="font-size:16px;" colspan="3">表二 测最小偏向角及数据处理</th>
                </tr>
                <tr>
                    <th>次数</th>
                    <td>1</td>
                    <td>2</td>
                </tr>
                <tr>
                    <th>θ1（前两项必填）</th>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta1-1-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta1-1-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta1-1">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta1-2-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta1-2-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta1-2">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>θ0（前两项必填）</th>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta0-1-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta0-1-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta0-1">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta0-2-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta0-2-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta0-2">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>θ1＇（前两项必填）</th>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta1p-1-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta1p-1-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta1p-1">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta1p-2-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta1p-2-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta1p-2">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>θ0＇（前两项必填）</th>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta0p-1-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta0p-1-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta0p-1">
                            <span>°</span>
                        </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" class="input-field2" id="2theta0p-2-du">
                            <span>°</span>
                            <input type="text" class="input-field2" id="2theta0p-2-fen">
                            <span>′=</span>
                            <input type="text" class="input-field2" id="2theta0p-2">
                            <span>°</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>θ1-θ0（度）</th>
                    <td><input type="text" class="input-field" id="2theta1-theta0-1"></td>
                    <td><input type="text" class="input-field" id="2theta1-theta0-2"></td>
                </tr>
                <tr>
                    <th>θ1＇-θ0＇（度）</th>
                    <td><input type="text" class="input-field" id="2theta1p-theta0p-1"></td>
                    <td><input type="text" class="input-field" id="2theta1p-theta0p-2"></td>
                </tr>
                <tr>
                    <th>最小偏向角的测量结果（度）</th>
                    <td><input type="text" class="input-field" id="min-pianxiang-1"></td>
                    <td><input type="text" class="input-field" id="min-pianxiang-2"></td>
                </tr>
                <tr>
                    <th>最小偏向角平均值（度）</th>
                    <td colspan="2">
                        <input style="width: 210px;" type="text" class="input-field" id="1683">
                    </td>
                </tr>
                <tr>
                    <th>最小偏向角的误差（度）</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="最小偏向角的误差（度）" class="input-field" id="1684"></td>
                </tr>
                <tr>
                    <th>最小偏向角的结果表示（度）</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="最小偏向角的结果表示（度）" class="input-field" id="1685" value="±"></td>
                </tr>
                <tr>
                    <th>折射率计算结果</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="折射率计算结果" class="input-field" id="1686"></td>
                </tr>
                <tr>
                    <th>折射率的标准误差</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="折射率的标准误差" class="input-field" id="1687"></td>
                </tr>
                <tr>
                    <th>折射率的结果表示</th>
                    <td colspan="2"><input style="
            width: 210px;
        " type="text" name="折射率的结果表示" class="input-field" id="1692" value="±"></td>
                </tr>
            </tbody>
        </table>
    </div>

    <script>
        // 高精度数字，设置四舍六入五凑偶
        BigNumber.set({ ROUNDING_MODE: BigNumber.ROUND_HALF_EVEN });

        function setInputValue(cellId, c_value) {
            document.getElementById(cellId).value = c_value;
        }

        function setCellValue(cellId, value) {
            document.getElementById(cellId).textContent = value;
        }

        function getInputValue(cellId) {
            return document.getElementById(cellId).value;
        }

        function getCellValue(cellId) {
            return document.getElementById(cellId).textContent;
        }

        // 保留特定位有效数字，四舍六入五凑偶，传入BigNumber对象，返回保留好的文本
        function fixToSignificantDigits(bignum, fix) {
            return bignum.sd(fix).toString();
        }

        // 生成数据的结果表示，含不确定度修约，传入时应多保留几位
        // std(标准值)、uncertainty(不确定度)均为文本，fix为正整数表示要约到的小数位
        // 返回文本
        function RoundingUncertainty(std, uncertainty, fix) {
            let result = new BigNumber(std).toFixed(fix).toString() + "±";
            let u1st_i = 0;
            // 寻找不确定度的第一个有效数字的位置
            for (u1st_i = 0; u1st_i < uncertainty.length; u1st_i++) {
                if (uncertainty[u1st_i] != "0" && uncertainty[u1st_i] != ".") {
                    break;
                }
            }
            let themin_unit = new BigNumber("0." + "0".repeat(fix - 1) + "1");
            if (themin_unit.comparedTo(uncertainty) != -1) {
                u1st_i = uncertainty.length;
            }
            if (u1st_i == uncertainty.length) {
                // 说明不确定度是0或者小于最小单位
                // 取最小单位即可
                return result + themin_unit.toString();
            }
            let the2ndmin_unit = themin_unit.times(10);
            let wantfix = 1;
            if (uncertainty[u1st_i] < 3) {
                if (the2ndmin_unit.comparedTo(uncertainty) != 1) {
                    // 小于3并且位数允许保留两位小数
                    wantfix = 2;
                }
            }
            // 保留到极限值的后一位，供后面判断进位
            uncertainty = new BigNumber(uncertainty).toFixed(fix + 1, BigNumber.ROUND_FLOOR).toString();
            // 寻找不确定度的第一个有效数字的位置
            for (u1st_i = 0; u1st_i < uncertainty.length; u1st_i++) {
                if (uncertainty[u1st_i] != "0" && uncertainty[u1st_i] != ".") {
                    break;
                }
            }
            // 找第二个有效数字
            let u2nd_i = u1st_i + 1;
            if (uncertainty[u2nd_i] == ".") {
                u2nd_i++;
            }
            if (wantfix == 2) {
                // 留两位有效数字，把第二个当成一，然后第三个当成二，这样子就能复用保留一位的逻辑
                u1st_i = u2nd_i;
                u2nd_i = u1st_i + 1;
                if (uncertainty[u2nd_i] == ".") {
                    u2nd_i++;
                }
            }
            // 判断进位
            if (uncertainty[u2nd_i] != "0") {
                // 要进位，构造加1的文本
                let added_unitStr = "";
                for (let i = 0; i < uncertainty.length; i++) {
                    if (i == u1st_i) {
                        added_unitStr += "1";
                    } else if (uncertainty[i] != ".") {
                        added_unitStr += "0";
                    } else {
                        added_unitStr += ".";
                    }
                }
                // 执行加一，非零的下一位会保证如果有后缀0不会消失
                uncertainty = new BigNumber(uncertainty).plus(added_unitStr).toString();
            }
            // 截取字符串并且返回
            return result + uncertainty.substring(0, u1st_i + 1);
        }

        var xgmm = new BigNumber("0.05"); // 0.05g的天平感量
        var data = {};
        var resfix = [3, 3, 4, 2, 2];

        // 根据data对象设置编辑框的值
        function setData() {
            for (let i = 1; i <= 5; i++) {
                setInputValue("a" + i, data.a[i - 1].toString());
                setInputValue("b" + i, data.b[i - 1].toString());
                setInputValue("h" + i, data.h[i - 1].toString());
            }
            setInputValue("p0", data.p0.toString());
            setInputValue("mAir", data.mAir.toString());
            setInputValue("m", data.m.toString());
            setInputValue("m2", data.m2.toString());
            setInputValue("m3", data.m3.toString());
        }

        // 获取输入的值，写入data对象
        function getData() {
            data = {
                a: [],
                b: [],
                h: [],
                p0: null,
                mAir: null,
                m: null,
                m2: null,
                m3: null,
            };
            for (let i = 1; i <= 5; i++) {
                data.a.push(new BigNumber(getInputValue("a" + i)));
                data.b.push(new BigNumber(getInputValue("b" + i)));
                data.h.push(new BigNumber(getInputValue("h" + i)));
            }
            data.p0 = new BigNumber(getInputValue("p0"));
            data.mAir = new BigNumber(getInputValue("mAir"));
            data.m = new BigNumber(getInputValue("m"));
            data.m2 = new BigNumber(getInputValue("m2"));
            data.m3 = new BigNumber(getInputValue("m3"));
            resfix = eval(getInputValue("resfix"));
        }

        //剪切板导出
        function handleExport() {
            // 输入的内容读取到data对象中
            getData();
            //需要导出的字符串
            var saveText = JSON.stringify(data);
            const el = document.createElement("textarea");
            el.value = saveText;
            document.body.appendChild(el);
            el.select();
            try {
                document.execCommand("copy");
                alert("已成功导出到剪切板");
            } catch (err) {
                alert("复制失败：" + err);
            }
            document.body.removeChild(el);
        }

        //处理文本导入
        function handleImport() {
            var input = prompt("请输入文本内容：");
            if (input !== null) {
                data = JSON.parse(input);
                setData();
                DoCalculate();
            }
        }

        var cdata = {};
        var rdata = {};
        function innerCalculate() {
            cdata = {
                // 长度a的平均值(cm)
                aavg: null,
                // 宽度b的平均值(cm)
                bavg: null,
                // 高度h的平均值(cm)
                havg: null,
                // 长度a的标准偏差(cm)
                xgma: null,
                // 宽度b的标准偏差(cm)
                xgmb: null,
                // 高度h的标准偏差(cm)
                xgmh: null,
                // 密度ρ的平均值(g/cm³)
                pavg: null,
                // 密度ρ的相对不确定度Eρ
                Ep1: null,
                // 密度ρ的不确定度σρ(g/cm³)
                xgmp1: null,
                // -----------------------
                //密度ρ(g/cm³)
                p2: null,
                //密度ρ的相对不确定度Eρ
                Ep2: null,
                //密度ρ的不确定度σρ(g/cm³)
                xgmp2: null,
            };

            rdata = {
                // 长度a的结果表示(cm)
                a: null,
                // 宽度b的结果表示(cm)
                b: null,
                // 高度h的结果表示(cm)
                h: null,
                // 密度ρ的结果表示(g/cm³)
                p1: null,
                // -----------------------
                //密度ρ的结果表示(g/cm³)
                pres: null,
            };
            // 均值计算
            cdata.aavg = new BigNumber(0);
            cdata.bavg = new BigNumber(0);
            cdata.havg = new BigNumber(0);
            for (let i = 0; i < 5; i++) {
                cdata.aavg = cdata.aavg.plus(data.a[i]);
                cdata.bavg = cdata.bavg.plus(data.b[i]);
                cdata.havg = cdata.havg.plus(data.h[i]);
            }
            cdata.aavg = cdata.aavg.div(5).sd(5);
            cdata.bavg = cdata.bavg.div(5).sd(5);
            cdata.havg = cdata.havg.div(5).sd(5);
            // 标准偏差计算
            cdata.xgma = new BigNumber(0);
            cdata.xgmb = new BigNumber(0);
            cdata.xgmh = new BigNumber(0);
            for (let i = 0; i < 5; i++) {
                cdata.xgma = cdata.xgma.plus(data.a[i].minus(cdata.aavg).pow(2));
                cdata.xgmb = cdata.xgmb.plus(data.b[i].minus(cdata.bavg).pow(2));
                cdata.xgmh = cdata.xgmh.plus(data.h[i].minus(cdata.havg).pow(2));
            }
            cdata.xgma = cdata.xgma.div(4).sqrt().sd(5);
            cdata.xgmb = cdata.xgmb.div(4).sqrt().sd(5);
            cdata.xgmh = cdata.xgmh.div(4).sqrt().sd(5);
            // 长宽高结果表示
            rdata.a = RoundingUncertainty(cdata.aavg.toString(), cdata.xgma.toString(), resfix[0]);
            rdata.b = RoundingUncertainty(cdata.bavg.toString(), cdata.xgmb.toString(), resfix[1]);
            rdata.h = RoundingUncertainty(cdata.havg.toString(), cdata.xgmh.toString(), resfix[2]);
            // 密度平均值计算
            cdata.pavg = data.mAir.div(cdata.aavg.times(cdata.bavg).times(cdata.havg)).sd(5);
            // 密度的相对不确定度
            cdata.Ep1 = new BigNumber(0);
            cdata.Ep1 = cdata.Ep1.plus(xgmm.div(data.mAir).pow(2));
            cdata.Ep1 = cdata.Ep1.plus(cdata.xgma.div(cdata.aavg).pow(2));
            cdata.Ep1 = cdata.Ep1.plus(cdata.xgmb.div(cdata.bavg).pow(2));
            cdata.Ep1 = cdata.Ep1.plus(cdata.xgmh.div(cdata.havg).pow(2));
            cdata.Ep1 = cdata.Ep1.sqrt().sd(5);
            // 密度的不确定度
            cdata.xgmp1 = cdata.pavg.times(cdata.Ep1).sd(5);
            // 密度结果表示
            rdata.p1 = RoundingUncertainty(cdata.pavg.toString(), cdata.xgmp1.toString(), resfix[3]);

            // -----------------------

            // 密度的计算
            cdata.p2 = data.m.div(data.m3.minus(data.m2)).times(data.p0).sd(5);
            // 密度的相对不确定度
            cdata.Ep2 = new BigNumber(0);
            cdata.Ep2 = cdata.Ep2.plus(new BigNumber(1).div(data.m).pow(2));
            cdata.Ep2 = cdata.Ep2.plus(new BigNumber(1).div(data.m3.minus(data.m2)).pow(2).times(2));
            cdata.Ep2 = cdata.Ep2.sqrt().times(xgmm).sd(5);
            // 密度的不确定度
            cdata.xgmp2 = cdata.p2.times(cdata.Ep2).sd(5);
            // 密度结果表示
            rdata.pres = RoundingUncertainty(cdata.p2.toString(), cdata.xgmp2.toString(), resfix[4]);
        }
        function showDataRes() {
            for (let key in cdata) {
                setCellValue(key, cdata[key].toString());
            }
            for (let key in rdata) {
                setCellValue(key, rdata[key]);
            }
        }
        function DoCalculate() {
            // 获取输入
            getData();
            // 计算数据
            innerCalculate();
            // 结果显示
            showDataRes();
        }
        function genAutoEleReportFillingJSCode() {
            let data1str = "";
            for (let i = 1723; i <= 1727; i++) {
                data1str += `document.getElementById("${i.toString()}").value = "${data.a[i - 1723].toFixed(3)}";\n`;
            }
            let data2str = "";
            for (let i = 1730; i <= 1734; i++) {
                data2str += `document.getElementById("${i.toString()}").value = "${data.b[i - 1730].toFixed(3)}";\n`;
            }
            let data3str = "";
            for (let i = 1737; i <= 1741; i++) {
                data3str += `document.getElementById("${i.toString()}").value = "${data.h[i - 1737].toFixed(4)}";\n`;
            }
            let the_code = `// 天平感量（克）
document.getElementById("1761").value = "0.05";
// 质量m测量结果（克）
document.getElementById("1744").value = "${data.mAir.toFixed(2)}";
// 长度a的测量结果（厘米）
${data1str}// 宽度b测量结果（厘米）
${data2str}// 高度h的测量结果（厘米）
${data3str}// 长度a平均值（厘米）
document.getElementById("1728").value = "${cdata.aavg.toString()}";
// 宽度b平均值（厘米）
document.getElementById("1735").value = "${cdata.bavg.toString()}";
// 高度h的平均值（厘米）
document.getElementById("1742").value = "${cdata.havg.toString()}";
// 长度a的标准误差（厘米）
document.getElementById("1729").value = "${cdata.xgma.toString()}";
// 宽度b的标准误差（厘米）
document.getElementById("1736").value = "${cdata.xgmb.toString()}";
// 高度h的标准误差（厘米）
document.getElementById("1743").value = "${cdata.xgmh.toString()}";
// 密度的平均值（克/立方厘米）
document.getElementById("1745").value = "${cdata.pavg.toString()}";
// 密度的相对误差(%)
document.getElementById("1746").value = "${cdata.Ep1.times(100).toString()}";
// 密度的标准误差（克/立方厘米）
document.getElementById("1747").value = "${cdata.xgmp1.toString()}";
// 密度的结果表示（克/立方厘米）
document.getElementById("1748").value = "${rdata.p1}";
// 质量m1测量结果（克）
document.getElementById("1749").value = "${data.m.toFixed(2)}";
// 两个同时浸没在水中质量m2（克）
document.getElementById("1750").value = "${data.m2.toFixed(2)}";
// 一个水中一个水外的质量m3（克）
document.getElementById("1751").value = "${data.m3.toFixed(2)}";
// 水的密度（克/立方厘米）
document.getElementById("1752").value = "1";
// 石蜡密度（克/立方厘米）
document.getElementById("1753").value = "${cdata.p2.toString()}";
// 密度的相对误差(%)
document.getElementById("1754").value = "${cdata.Ep2.times(100).toString()}";
// 密度的标准误差（克/立方厘米）
document.getElementById("1755").value = "${cdata.xgmp2.toString()}";
//密度的结果表示（克/立方厘米）
document.getElementById("1756").value = "${rdata.pres}";`;
            const el = document.createElement("textarea");
            el.value = the_code;
            document.body.appendChild(el);
            el.select();
            try {
                document.execCommand("copy");
                alert("已成功导出到剪切板");
            } catch (err) {
                alert("复制失败：" + err);
            }
            document.body.removeChild(el);
        }
    </script>
</body>

</html>